﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "IFamily2DSketchCurve.h"
#include "GmFamilyService.h"
#include "ElementCreationOptions.h"

namespace gfam
{
    /// \brief Nurbs曲线的接口类
    class GM_FAMILY_SERVICE_EXPORT IFamily2DSketchNurbs : public gfam::IFamily2DSketchCurve
    {
        DEFINE_CAST_DERIVED(gfam::IFamily2DSketchNurbs, gfam::IFamily2DSketchCurve)
    public:

        /// \brief  创建Nurbs曲线
        ///  不指定节点矢量，由内部自动计算；并且不指定权值，所有控制点的权值设为1
        ///  软件内部创建样条曲线，通常使用这个方法
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  degree    度
        /// \param  controlPts 控制点
        /// \return Nurbs曲线
        static IFamily2DSketchNurbs* CreateByControlPoints(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , int degree
            , const std::vector<gcmp::Vector3d>& controlPts);

        /// \brief  创建Nurbs曲线
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  throughPts 通过点
        /// \return Nurbs曲线
        static IFamily2DSketchNurbs* CreateByThroughPoints(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , const std::vector<gcmp::Vector3d>& throughPts);

        /// \brief  创建图形表达
        virtual void CreateCurveGrep() = 0;

        /// \brief  获取是否通过点模式
        ///
        /// \param  是返回true，否则返回false
        virtual bool GetIsThroughPointsMode() const = 0;

        /// \brief  设置通过点模式
        ///
        /// \param isThroughPtsMode  模式
        virtual void SetIsThroughPointsMode(bool isThroughPtsMode) = 0;

        /// \brief  根据索引设置通过点
        ///
        /// \param index  索引
        /// \param newThroughtPoint  新的点坐标
        virtual void SetThroughPointByIndex(int index, const gcmp::Vector3d& newThroughtPoint) = 0;

        /// \brief  根据索引设置控制点
        ///
        /// \param index  索引
        /// \param newControlPoint  新的点坐标
        /// \param weight  权重
        virtual void SetControlPointByIndex(int index, const gcmp::Vector3d& newControlPoint, double weight = 1.0) = 0;
        
        /// \brief  获取通过点
        ///
        /// \return 通过点
        virtual std::vector<gcmp::Vector3d>& GetThroughPointsFW() = 0;

        /// \brief  获取Nurbs曲线的度
        ///
        /// \return Nurbs曲线的度
        virtual int GetDegree() const = 0;

        /// \brief  获取控制点
        ///
        /// \param controlPoints 控制点
        virtual void GetControlPoints(std::vector<gcmp::Vector3d>& controlPoints) const = 0;

        /// \brief  获取权重
        ///
        /// \param weights 权重
        virtual void GetWeights(std::vector<double>& weights) const = 0;

        /// \brief  获取节点向量
        ///
        /// \param knotVector 节点向量
        virtual void GetKnotVector(std::vector<double>& knotVector) const = 0;

    };
}